s h

s h

  • NA
  • 26
  • 4k

String.Split - How to calculate slot

Apr 4 2013 6:57 AM
Hello,

look im new in programming, would be awesome if u could help me.

Im reading a whole .csv File with this:


private void button3_Click(object sender, EventArgs e)
        {
            {
                var content = string.Empty;
                using (StreamReader reader = new StreamReader(@"C:/1.csv", System.Text.Encoding.Default))
                {
                    content = reader.ReadToEnd();
                    reader.Close();
                }

                content = content.Replace("\"", string.Empty);
                content = content.Replace("               ", "");
               content = content.Replace("             ", "");

                using (StreamWriter writer = new StreamWriter(@"C:/2.csv"))
                {
                    writer.Write(content);
                    writer.Close();
                }
            }
        }



1.CSV Input looks like this:


" 09000";"Catalaog 1";10148;234
" 09001";"Catalaog 2";0;345

2.CSV Outlooks like this:


09000~Catalaog 1~10148~234
09001~Catalaog 2~0~0


I need a rewrite of my Code that the last to slots 10148~234 get calculated.

String must look like this at the end:

09000~Catalaog 1~9914~234
09001~Catalaog 2~0~0

See the diffrence? The 10148 - 234 = 9914. The 10148 gets replaced with the result.

Could u rewrite my upper code and help me ?:<

Answers (20)